
********************************************************************************
clear

use "$clean/who_counts_mechanisms.dta"

** Mechanisms, Full Table, School Census **

** Regressions ** 

* Planning outcomes
xi: reghdfe school prcnt_etat_civil prcnt_for_1970 prcnt_modern_houses mean_elev cropland_1910 popd_1910 n_schools_52 n_classes_52 n_students_52, a(type_factor province colonizer) cluster(name_1972_final)
estadd local controls = "$\surd$",replace
estadd local adminFE = "$\surd$", replace 
estadd ysumm, replace
eststo m_school

xi: reghdfe n_school prcnt_etat_civil prcnt_for_1970 prcnt_modern_houses mean_elev cropland_1910 popd_1910 n_schools_52 n_classes_52 n_students_52, a(type_factor province colonizer) cluster(name_1972_final)
estadd local controls = "$\surd$",replace
estadd local adminFE = "$\surd$", replace 
estadd ysumm, replace
eststo m_schools

* Quality Measure

xi: reghdfe mean_share_cm2 prcnt_etat_civil prcnt_for_1970 prcnt_modern_houses mean_elev cropland_1910 n_schools_52 n_classes_52 n_students_52, a(type_factor province colonizer) cluster(name_1972_final)
estadd local controls = "$\surd$",replace
estadd local adminFE = "$\surd$", replace 
estadd ysumm, replace
eststo m_cm2

xi: reghdfe mean_teacher_student prcnt_etat_civil prcnt_for_1970 prcnt_modern_houses mean_elev cropland_1910 popd_1910 n_schools_52 n_classes_52 n_students_52, a(type_factor province colonizer) cluster(name_1972_final)
estadd local controls = "$\surd$",replace
estadd local adminFE = "$\surd$", replace 
estadd ysumm, replace
eststo m_teacher_student

** Output Table **

#delimit ; 
estout m_school
	   m_schools
	   m_cm2
	   m_teacher_student
       using "${output}/tables/TableA23.tex",
       style(tex) 
       cells(b(star fmt(3)) se(par fmt(3))) 
varlabels(prcnt_etat_civil "Share Registered Households " prcnt_students_male "Share Male Students"  prcnt_students_female "Share Female Students" prcnt_for_1970 "Share Foreign Population" prcnt_modern_houses "Share Modern Houses" mean_elev "Mean Elevation" cropland_1910 "Estimated Precolonial Cropland" popd_1910 "Estimate Precolonial Population Density " mean_students_class "Students per Class, Mean" mean_teacher_student "Teacher Student Ratio, Mean" mean_share_cm2 "Share CM2, Mean" n_schools_52 "N Schools, 1952" n_classes_52 "N Classes, 1952" n_students_52 "N Students, 1952")
       drop(_cons)
	   stats(controls
	   adminFE
             r2 
             N
			 ymean, fmt(0 0 2 0 3 %9.0gc %9.0gc)
             labels("\hline Controls"
			 "\hline Admin FE"
                   "\hline \(R^2\)" 
                  " \hline N"
				   "Dep. Var. Mean "))
       mlabels(,none) 
       numbers
       collabels(none) 
       starl(* 0.1 ** 0.05 *** 0.01)
	          prehead( 
           \begin{table}[H]
           \caption{Registration, Infrastructure, and Quality, 1975}        
           \label{tab:MECH_1975_FULL}            
           \centering
           \begin{tabular}{@{\extracolsep{4pt}}l*{@M}{c}@{}} 
           \hline \hline             
		   & \multicolumn{1}{c}{School} 
		   & \multicolumn{1}{c}{Number of Schools} 
		   & \multicolumn{1}{c}{Share CM2}
		   & \multicolumn{1}{c}{Teacher Student Ratio}\\                         
       )
       posthead(\hline) 
       prefoot() 
       postfoot(
           \noalign{\smallskip} \hline \hline 
           \end{tabular}
           \medskip
           \begin{minipage}{.9\textwidth}
           \tiny \justify Notes: \( @starlegend \). 
           \\ Provincial Fixed Effects and Clustered Robust Standard Errors at Locality.
           \end{minipage}        
       \end{table}
       )
       replace;
#delimit cr
